import { ref } from 'vue'
export default function () {
  const speakText = ref(null)
  const speakPause = ref(null)
  const speakResume = ref(null)
  const speakStop = ref(null)
  const speakPlaying = ref(null)
  speakText.value = (text) => {
    if (typeof responsiveVoice !== 'undefined') {
      /* eslint-disable */
      responsiveVoice.speak(text, 'Chinese Male', { pitch: 1 })
    } else {
      console.error('ResponsiveVoice未定义')
    }
  }
  speakPause.value = () => {
    responsiveVoice.pause()
  }
  speakResume.value = () => {
    responsiveVoice.resume()
  }
  speakStop.value = () => {
    responsiveVoice.cancel()
  }
  speakPlaying.value = () => {
    return responsiveVoice.isPlaying()
  }
  return {
    speakText,
    speakPause,
    speakResume,
    speakStop,
    speakPlaying
  }
}
